Skip to content

feat: estimate transaction size in the FFI crate #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

CiottiGiorgio
Copy link
Member

@CiottiGiorgio CiottiGiorgio commented May 14, 2025

I thought this code is common enough we might want it in core.

I am still missing a way to do it in the rust crate. After I do that, the FFI crate should only re-expose what's in the core crate.

Also, I haven't taken the approach of actually signing it as it is a slow operation. I decided to attach an invalid signature, encode, and get the size.

I've also seen a bunch of times just adding 75 to the encoding length without a signature. I am assuming 75 comes up from the field name, the encoding and the signature length.
What approach do we think is best?

@neilcampbell
Copy link
Collaborator

neilcampbell commented May 16, 2025

I've also seen a bunch of times just adding 75 to the encoding length without a signature. I am assuming 75 comes up from the field name, the encoding and the signature length.

Yeah that's what the JS SDK does too. I think we keep the logic the same.

@CiottiGiorgio
Copy link
Member Author

Huh. Interesting. I'll make the change.

@@ -59,6 +59,12 @@ impl AssetTransferTransactionBuilder {
impl AlgorandMsgpack for Transaction {}
impl TransactionId for Transaction {}

impl EstimateTransactionSize for Transaction {
fn estimate_size(&self) -> Result<usize, AlgoKitTransactError> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth adding a simple test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants